import type { BannerItem, PageResult, PageParams } from '@/types/global'
import type { CategoryItem, GuessItem, HotItem } from '@/types/home'
import http from '@/utils/https'

/**
 * 获取轮播广告图数据
 * @param {number} [distributionSite] - 广告区域展示位置：1 为首页（默认值） 2 为商品分类页
 * @returns {Promise}
 */
export function getHomeBannerAPI(distributionSite = 1) {
  return http<BannerItem[]>({
    method: 'GET',
    url: '/home/banner',
    data: {
      distributionSite,
    },
  })
}

/**
 * 获取首页商品分类数据
 * @returns {Promise}
 */
export function getHomeCategoryAPI() {
  return http<CategoryItem[]>({
    method: 'GET',
    url: '/home/category/mutli',
  })
}

/**
 * 获取首页热门推荐数据
 * @returns {Promise}
 */
export function getHomeHotAPI() {
  return http<HotItem[]>({
    method: 'GET',
    url: '/home/hot/mutli',
  })
}

/**
 * 获取猜你喜欢商品数据
 * @param {Object} params
 * @param {number} [params.page] - 页码默认值1
 * @param {number} [params.pageSize] - 每页条数默认值10
 * @returns {Promise}
 */
export function getHomeGuessLikeAPI(params: PageParams) {
  return http<PageResult<GuessItem>>({
    method: 'GET',
    url: '/home/goods/guessLike',
    data: params,
  })
}
